import React from "react";
import { useNavigate } from "react-router-dom";
import { Button, Result } from "antd";
import { MANAGE_LIST_PATHNAME } from "../router";
import { ResultStatusType } from "antd/es/result";
import styles from "./Error.module.scss";

type Props = {
  status?: ResultStatusType;
  title?: string;
  subTitle?: string;
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  extra?: any;
};

const Error: React.FC<Props> = ({
  status = "404",
  title = "404",
  subTitle = "抱歉，您访问的页面不存在",
  extra,
}) => {
  const nav = useNavigate();
  if (!extra)
    extra = (
      <Button type="primary" onClick={() => nav(MANAGE_LIST_PATHNAME)}>
        返回
      </Button>
    );

  return (
    <div className={styles["error-container"]}>
      <Result
        {...{
          status,
          title,
          subTitle,
          extra,
        }}
      />
    </div>
  );
};
export default Error;
